package com.hsjk.szwj.module.smedia.controller.admin.mediaManager;

import com.hsjk.szwj.framework.common.pojo.CommonResult;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.GetMediaInfosReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.GetMediaInfosRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.MediaBasicInfosReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.MediaBasicInfosRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.MediaInfoReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.MediaInfoRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.PublicMediaBasicInfosReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.PublicMediaBasicInfosRespVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.PublicMediaTagsListReqVO;
import com.hsjk.szwj.module.smedia.controller.admin.mediaManager.vo.PublicMediaTagsListRespVO;
import com.hsjk.szwj.module.smedia.service.mediaManager.IMediaLibrary;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.hsjk.szwj.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 媒资管理")
@RestController
@RequestMapping("/system/media-manager")
@Validated
public class MediaManagerController {

    @Resource
    private IMediaLibrary mediaLibrary;

    @PostMapping("/list-public-media-basic-infos")
    @Operation(summary = "获取公共素材库媒资基础信息")
    @PreAuthorize("@ss.hasPermission('system:media-manager:query')")
    public CommonResult<PublicMediaBasicInfosRespVO> listPublicMediaBasicInfos(@Valid @RequestBody PublicMediaBasicInfosReqVO reqVO) {
        return success(mediaLibrary.listPublicMediaBasicInfos(reqVO));
    }

    @PostMapping("/media-info")
    @Operation(summary = "获取媒资内容信息")
    @PreAuthorize("@ss.hasPermission('system:media-manager:query')")
    public CommonResult<MediaInfoRespVO> mediaInfo(@Valid @RequestBody MediaInfoReqVO reqVO) {
        return success(mediaLibrary.mediaInfo(reqVO));
    }

    @PostMapping("/list-media-basic-infos")
    @Operation(summary = "获取媒资内容列表")
    @PreAuthorize("@ss.hasPermission('system:media-manager:query')")
    public CommonResult<MediaBasicInfosRespVO> listMediaBasicInfos(@Valid @RequestBody MediaBasicInfosReqVO reqVO) {
        return success(mediaLibrary.listMediaBasicInfos(reqVO));
    }

    @PostMapping("/list-all-public-media-tags")
    @Operation(summary = "获取公共素材库媒资的所有标签信息")
    @PreAuthorize("@ss.hasPermission('system:media-manager:query')")
    public CommonResult<PublicMediaTagsListRespVO> listAllPublicMediaTags(@Valid @RequestBody PublicMediaTagsListReqVO reqVO) {
        return success(mediaLibrary.listAllPublicMediaTags(reqVO));
    }

    @PostMapping("/batch-get-media-infos")
    @Operation(summary = "批量获取媒体信息")
    @PreAuthorize("@ss.hasPermission('system:media-manager:query')")
    public CommonResult<GetMediaInfosRespVO> batchGetMediaInfos(@Valid @RequestBody GetMediaInfosReqVO reqVO) {
        return success(mediaLibrary.batchGetMediaInfos(reqVO));
    }
}
